<?php
    function curl_get($url='',$data=[],$timeout=30){
        if($url==''||$timeout<=0){
            return false;       
        }

        if(!empty($data) && is_array($data)) $url = $url.'?'.http_build_query($data);
        $ch = curl_init((string)$url);
        curl_setopt($ch,CURLOPT_HEADER,0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch, CURLOPT_TIMEOUT, (int)$timeout);
        $res = curl_exec($ch);
        curl_close($ch);

        return $res;
    }
    function curl_post($url='',$data=[],$timeout = 30){
        if($url == '' || empty($data) || $timeout <=0){
            return false;
        }
        $ch = curl_init((string)$url);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
        curl_setopt($ch, CURLOPT_POST,1);
        curl_setopt($ch, CURLOPT_TIMEOUT,(int)$timeout);
        $res = curl_exec($ch);
        curl_close($ch);
        return $res; 
    }
    echo curl_post('http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx',['name'=>'cjw']);

    /**
     * isset和empty区别
     */
    $arr = ['a'=>0,'b'=>null];
    $arr2 = [];
    var_dump(isset($arr['a']));//true
    var_dump(isset($arr['b']));//存在只有为null，为false
    var_dump(isset($arr['c']));//false
    var_dump(isset($arr));//true
    //存在且值为""、0、"0"、NULL、、FALSE、array()、var $var;以及没有任何属性的对象
    var_dump(empty($arr['a']));//true
    var_dump(empty($arr['b']));//true
    var_dump(empty($arr));//false
    var_dump(empty($arr2));//true
    //当要判断一个变量存在且不为空，先isset函数，再用empty函数
    